package cn.wolfcode.p2p.business.domain;

import cn.wolfcode.p2p.base.domain.BaseAudit;
import cn.wolfcode.p2p.util.Constants;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.Date;
import java.util.HashMap;

@Getter@Setter
public class RechargeOffline extends BaseAudit{
    private String tradeCode;//交易号

    /**
     * 指定索引更改成*,处理敏感信息的方法
     * @param args
     */
    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder("1234567890");
        StringBuilder replace = sb.replace(3, 8, "******");
        System.out.println(replace);
    }
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date tradeTime;//充值时间

    private BigDecimal amount;//充值金额

    private String note;//充值说明

    private UserBankInfo bankInfo;//关联银行卡

    public String getJsonString(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("username",getApplier().getUsername());
        map.put("tradeCode",tradeCode);
        map.put("amount",amount.setScale(Constants.BIDREQUEST_STATE_UNDO,BigDecimal.ROUND_HALF_UP));
        map.put("tradeTime", DateFormat.getDateTimeInstance().format(tradeTime));
        return JSON.toJSONString(map);
    }

}